import baidubce
from baidubce.auth import bce_credentials
from baidubce import bce_client_configuration
from baidubce.services.bos import bos_client, canned_acl

from s25 import local_settings as settings


config = bce_client_configuration.BceClientConfiguration(
    credentials=bce_credentials.BceCredentials(
        access_key_id=settings.BOS_ACCESS_KEY_ID,
        secret_access_key=settings.BOS_SECRET_ACCESS_KEY,
    ),
    endpoint=settings.BOS_ENDPOINT,
    protocol=baidubce.protocol.HTTPS
)

# 获取客户端对象
client = bos_client.BosClient(config)

bucket_name = 'test-15861795215'
# 创建桶
if not client.does_bucket_exist(bucket_name):
    client.create_bucket(bucket_name)
    client.set_bucket_canned_acl(bucket_name, canned_acl.PUBLIC_READ)